home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / menu_dvd.swf / scripts / __Packages / EmbedHtmlMenuCellRenderer.as < prev    next >
Text File  |  2007-11-07  |  4KB  |  146 lines

  1. class EmbedHtmlMenuCellRenderer extends mx.core.UIComponent
  2. {
  3.    static var style_sheet = null;
  4.    var previousLabel = null;
  5.    function EmbedHtmlMenuCellRenderer()
  6.    {
  7.       super();
  8.       this.cssStyle = "menuRowTextEmbed";
  9.    }
  10.    function createChildren(Void)
  11.    {
  12.       if(this.htmlComponent == undefined)
  13.       {
  14.          this.createLabel("htmlComponent",1);
  15.       }
  16.       this.htmlComponent.html = true;
  17.       this.htmlComponent.border = false;
  18.       this.htmlComponent.multiline = false;
  19.       this.htmlComponent.wordWrap = false;
  20.       this.htmlComponent.selectable = false;
  21.       this.htmlComponent.styleSheet = EmbedHtmlMenuCellRenderer.style_sheet;
  22.       this.htmlComponent.embedFonts = true;
  23.       this.htmlComponent.antiAliasType = "advanced";
  24.       this.htmlComponent.sharpness = -300;
  25.       this.htmlComponent.thickness = -50;
  26.       this._parent.drawRowFill = this.drawRowFill;
  27.       this.size();
  28.    }
  29.    function size(Void)
  30.    {
  31.       this.htmlComponent.setSize(this.__width,this.__height - 2);
  32.       var deltaY = 2;
  33.       if(EmbedHtmlMenuCellRenderer.style_sheet)
  34.       {
  35.          var style = EmbedHtmlMenuCellRenderer.style_sheet.getStyle("." + this.cssStyle);
  36.          if(style)
  37.          {
  38.             deltaY = Math.max(0,Math.floor((this.__height - style.fontSize - 1 - 2) / 2));
  39.          }
  40.       }
  41.       trace(deltaY);
  42.       this.htmlComponent._y = deltaY;
  43.    }
  44.    function setValue(str, item, sel)
  45.    {
  46.       if(item == undefined)
  47.       {
  48.          this.htmlComponent.htmlText = str;
  49.          this.previousLabel = null;
  50.          return undefined;
  51.       }
  52.       var columnIndex = this.columnIndex;
  53.       var columnName = this.getDataLabel();
  54.       var htmlTxt = str;
  55.       var labelSupSub = this.HtmlFunction(item.label);
  56.       htmlTxt = "<span class=\'" + this.cssStyle + "\'>" + labelSupSub + "</span>";
  57.       this.htmlComponent.htmlText = htmlTxt;
  58.       if(item.cellEnabled == false && !this.disableRect)
  59.       {
  60.          this.disableRect = this.createRectangle(-2,0,this.__width + 2,this.__height + 1,16777215,"disableRect");
  61.          this.disableRect.onPress = function()
  62.          {
  63.          };
  64.          this.disableRect.useHandCursor = false;
  65.          this.disableRect._alpha = 30;
  66.          this.setColor(this.owner.getStyle("disabledColor"));
  67.       }
  68.       if(item.cellEnabled == true && this.disableRect)
  69.       {
  70.          this.disableRect._visible = false;
  71.       }
  72.    }
  73.    function createRectangle(inX, inY, w, h, bgColor, name)
  74.    {
  75.       var mc = this.createEmptyMovieClip(name,this.getNextHighestDepth());
  76.       mc.beginFill(bgColor);
  77.       mc.lineTo(w,0);
  78.       mc.lineTo(w,h);
  79.       mc.lineTo(0,h);
  80.       mc.lineTo(0,0);
  81.       mc._x = inX;
  82.       mc._y = inY;
  83.       return mc;
  84.    }
  85.    function getPreferredHeight(Void)
  86.    {
  87.       if(this.owner == undefined)
  88.       {
  89.          return 18;
  90.       }
  91.       return this.owner.__height;
  92.    }
  93.    function HtmlFunction(inLabel)
  94.    {
  95.       if(inLabel.indexOf("<sup>") >= 0 || inLabel.indexOf("<sub>") >= 0)
  96.       {
  97.          return StringUtils.subSupFromHTML(inLabel);
  98.       }
  99.       return inLabel;
  100.    }
  101.    function setColor(col)
  102.    {
  103.       if(this.htmlComponent != undefined)
  104.       {
  105.          this.htmlComponent.textColor = col;
  106.       }
  107.    }
  108.    function drawRowFill(mc, newClr)
  109.    {
  110.       mc.clear();
  111.       mc.beginFill(16777215);
  112.       mc.drawRect(0,0,this.__width,this.__height);
  113.       mc.beginFill(newClr);
  114.       mc.drawRect(0,1,this.__width,this.__height);
  115.       mc.endFill();
  116.       mc._width = this.__width;
  117.       mc._height = this.__height;
  118.       mc._alpha = 90;
  119.    }
  120.    static function displayStyleSheet(my_styleSheet)
  121.    {
  122.       var styleNames = my_styleSheet.getStyleNames();
  123.       if(!styleNames.length)
  124.       {
  125.          trace("This is an empty style sheet.");
  126.       }
  127.       else
  128.       {
  129.          var i = 0;
  130.          while(i < styleNames.length)
  131.          {
  132.             var styleName = styleNames[i];
  133.             trace("Style " + styleName + ":");
  134.             var styleObject = my_styleSheet.getStyle(styleName);
  135.             for(var propName in styleObject)
  136.             {
  137.                var propValue = styleObject[propName];
  138.                trace("\t" + propName + ": " + propValue);
  139.             }
  140.             trace("");
  141.             i++;
  142.          }
  143.       }
  144.    }
  145. }
  146.